/**
*
*/
package info.kalendra.matrixOps;
import java.security.InvalidParameterException;
import info.kalendra.matrix.Matrix;
/**
* @author Eric Kalendra
*
*/
public class MatrixSumMatrixMatrix {
public Matrix sum(Matrix x, Matrix y, Matrix z){
//check dimensions
if(x.getDimensionRows() != y.getDimensionRows()){
throw new InvalidParameterException("Row Dimensions don't match");
}
if(x.getDimensionCols() != y.getDimensionCols()){
throw new InvalidParameterException("Col Dimensions don't match");
}
//set the dimensions of z
z.setDimensions(x.getDimensionRows(), x.getDimensionCols());
//push the data into z
for(int i = 0; i<x.getDimensionRows();i++){
for(int j =0; j <x.getDimensionCols(); j++){
z.setValue(i, j, x.getValue(i, j) + y.getValue(i, j));
}
}
return z;
}
}